import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BizActivityVo } from '@/api/operation/activity/types';

/**
 * 查询列表
 * @param query
 * @returns {*}
 */

export const listActivity = (query?: PageQuery): AxiosPromise<BizActivityVo[]> => {
  return request({
    url: '/biz-vendor/activity/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询详细
 * @param id
 */
export const getActivity = (id: string | number): AxiosPromise<BizActivityVo> => {
  return request({
    url: '/biz-vendor/activity/' + id,
    method: 'get'
  });
};

/**
 * 新增
 * @param data
 */
export const addActivity = (data: BizActivityVo) => {
  return request({
    url: '/biz-vendor/activity',
    method: 'post',
    data: data
  });
};

/**
 * 修改
 * @param data
 */
export const updateActivity = (data: BizActivityVo) => {
  return request({
    url: '/biz-vendor/activity',
    method: 'put',
    data: data
  });
};

/**
 * 删除
 * @param id
 */
export const delActivity = (id: Array<string | number>) => {
  return request({
    url: '/biz-vendor/activity/' + id,
    method: 'delete'
  });
};

/**
 * 开始
 * @param data
 */
export const startActivity = (id) => {
  return request({
    url: '/biz-vendor/activity/start/' + id,
    method: 'put'
  });
};

/**
 * 结束
 * @param data
 */
export const stopActivity = (id) => {
  return request({
    url: '/biz-vendor/activity/stop/' + id,
    method: 'put'
  });
};

/**
 * 用户领卷列表
 * @param data
 */
export const couponList = (query) => {
  return request({
    url: '/biz-vendor/activityCouponRedemption/list',
    method: 'get',
    params: query
  });
};

/**
 * 定向发放
 * @param data
 * @returns
 */
export const targeted = (data) => {
  return request({
    url: '/biz-vendor/activity/redemption/targeted/' + data.openId + '/' + data.activityId + '/' + data.number,
    method: 'post'
  });
};

/**
 * 定向投放列表
 * @param data
 */
export const targetedList = (query) => {
  return request({
    url: '/biz-vendor/activityCouponTargeted/list',
    method: 'get',
    params: query
  });
};
